package com.maixy.dailydemo.basis;

import org.springframework.cglib.proxy.Enhancer;

import java.lang.reflect.Proxy;

/**
 * @ClassName BasisTest
 * @Description TODO
 * @Date 2023/3/24 11:50
 * @Author Maixy
 */
public class BasisTest {

    public static void main(String[] args) {
        //Class<Radiation> radiationClass = Radiation.class;
        //System.out.println(radiationClass.getPackage().getName());
        //System.out.println(radiationClass.getName());
        //System.out.println(radiationClass.getPackage().getName());


        IPerson target = new ManPerson();
        IPerson proxy = (IPerson) Proxy.newProxyInstance(
                target.getClass().getClassLoader(),
                target.getClass().getInterfaces(),
                new PersonInvocationHandler(target));
        proxy.eat();
        proxy.sleep();

        System.out.println("===============");

        Person cglproxy = (Person) Enhancer.create(Person.class, new PersonMethodInterceptor());
        cglproxy.eat();
        cglproxy.sleep();

    }
}
